package edu.hcmus.sow.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAclClassByClass_", query = "select myAclClass from AclClass myAclClass where myAclClass.class_ = ?1"),
		@NamedQuery(name = "findAclClassByClass_Containing", query = "select myAclClass from AclClass myAclClass where myAclClass.class_ like ?1"),
		@NamedQuery(name = "findAclClassById", query = "select myAclClass from AclClass myAclClass where myAclClass.id = ?1"),
		@NamedQuery(name = "findAclClassByPrimaryKey", query = "select myAclClass from AclClass myAclClass where myAclClass.id = ?1"),
		@NamedQuery(name = "findAllAclClasss", query = "select myAclClass from AclClass myAclClass") })
@Table(catalog = "sow", name = "acl_class")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "SharedOnlineWorkspace/edu/hcmus/sow/domain", name = "AclClass")
@XmlRootElement(namespace = "SharedOnlineWorkspace/edu/hcmus/sow/domain")
public class AclClass implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "ID", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "CLASS", length = 100, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String class_;

	/**
	 */
	@OneToMany(mappedBy = "aclClass", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.AclObjectIdentity> aclObjectIdentities;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setClass_(String class_) {
		this.class_ = class_;
	}

	/**
	 */
	public String getClass_() {
		return this.class_;
	}

	/**
	 */
	public void setAclObjectIdentities(Set<AclObjectIdentity> aclObjectIdentities) {
		this.aclObjectIdentities = aclObjectIdentities;
	}

	/**
	 */
	@JsonIgnore
	public Set<AclObjectIdentity> getAclObjectIdentities() {
		if (aclObjectIdentities == null) {
			aclObjectIdentities = new java.util.LinkedHashSet<edu.hcmus.sow.domain.AclObjectIdentity>();
		}
		return aclObjectIdentities;
	}

	/**
	 */
	public AclClass() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(AclClass that) {
		setId(that.getId());
		setClass_(that.getClass_());
		setAclObjectIdentities(new java.util.LinkedHashSet<edu.hcmus.sow.domain.AclObjectIdentity>(that.getAclObjectIdentities()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("class_=[").append(class_).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof AclClass))
			return false;
		AclClass equalCheck = (AclClass) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
